package com.buli.blmall.admin.system.controller;

import org.springframework.web.bind.annotation.*;
import com.buli.blmall.admin.system.service.SysUserService;
import com.buli.blmall.admin.system.vo.SysUserVO;
import com.buli.blmall.admin.base.BaseController;
import com.buli.blmall.admin.common.response.Result;
import java.util.List;
import lombok.AllArgsConstructor;


/**
 * <p>
 * 用户 前端控制器
 * </p>
 *
 * @author buli
 * @since 2024-12-20
 */
@RestController
@RequestMapping("system/sys_user")
@AllArgsConstructor
public class SysUserController extends BaseController {

    private SysUserService sysUserService;

    /**
     * 查询用户详情
     *
     * @param id 用户ID
     */
    @GetMapping("/{id}")
    public Result<SysUserVO> getsysUser(@PathVariable Long id) {
        return Result.success(sysUserService.info(id));
    }

    /**
     * 查询用户集合
     *
     * @param sysUserVo
     */
    @GetMapping("/list")
    public Result<List<SysUserVO>> listSysUser(SysUserVO sysUserVo) {
        return Result.success(sysUserService.queryList(sysUserVo));
    }

    /**
     * 添加用户
     * @param sysUserVo
     */
    @PostMapping("/add")
    public Result<Boolean> addSysUser(@RequestBody SysUserVO sysUserVo) {
        return Result.success(sysUserService.add(sysUserVo));
    }

    /**
     * 修改用户
     * @param sysUserVo
     */
    @PutMapping("/edit")
    public Result<Boolean> editSysUser(@RequestBody SysUserVO sysUserVo) {
        return Result.success(sysUserService.edit(sysUserVo));
    }

    /**
     * 删除用户
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public Result<Boolean> removeSysUser(@PathVariable Long id) {
        return Result.success(sysUserService.removeById(id));
    }

}

